﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class MasterPage : System.Web.UI.MasterPage
{ 
        private int TypeId;
        private string name;
        DataClassesDataContext db = new DataClassesDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack == true)
        {
            if (Session["phone"] == null || Session["phone"].ToString() == string.Empty)
            {
                //ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script>alert('登陆过期，请重新登陆！');location='../../login.aspx'</script>");
                Response.Write("<script>alert('登陆过期，请重新登陆！');location='../../login.aspx'</script>");
                return;
            }
        }
        lr_Time.Text = DateTime.Now.ToString();
            TypeId = Convert.ToInt32(Session["type"]);
            //.Text =Convert.ToString(Session["name"]);
            GetRole();
            Label2.Text = Convert.ToString(Session["name"]);
    }
    private void GetRole()
    {
        GridView1.DataSourceID = "";
        int? username = null;
        if (TypeId == 1)
        {
            string phone =  (string)Session["phone"];
            var df = (from m in db.proc_GetAdmInfobyPwd(phone)
                      select m).First();
            username = df.userName;
        }
        var ds = (from m in db.proc_GetAdminAutority(username, TypeId)
                  select m);
         GridView1. DataSource = ds;
         GridView1.DataBind();
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}
